home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Xconq 7.0d37 / lib / stdunit.g < prev    next >
Text File  |  1995-05-04  |  15KB  |  571 lines

  1. (game-module "stdunit"
  2.   (blurb "Standard unit types and tables")
  3.   )
  4.  
  5. ;;; New format version of the standard game.  This file is just types and
  6. ;;; tables, is not a complete game (see "standard" for that).
  7.  
  8. (unit-type infantry (image-name "soldiers")
  9.   (help "marches around and captures things"))
  10. (unit-type armor (image-name "tank")
  11.   (help "faster than infantry, limited to open terrain"))
  12. (unit-type fighter (image-name "fighter")
  13.   (help "interceptor to get those nasty bombers"))
  14. (unit-type bomber (image-name "4e")
  15.   (help "long range aircraft, carries infantry and bombs"))
  16. (unit-type destroyer (image-name "dd")
  17.   (help "fast, cheap, and sinks subs"))
  18. (unit-type submarine (image-name "sub")
  19.   (help "sneaks around and sinks ships"))
  20. (unit-type troop-transport (name "troop transport") (image-name "ap")
  21.   (help "carries infantry and armor across the pond"))
  22. (unit-type carrier (image-name "cv") (char "C")
  23.   (help "carries fighters and bombers around"))
  24. (unit-type battleship (image-name "bb") (char "B")
  25.   (help "the most powerful ship"))
  26. (unit-type nuclear-bomb (name "nuclear bomb") (image-name "bomb") (char "N")
  27.   (help "leveler of cities (and anything else)"))
  28. (unit-type base (image-name "airbase") (char "/")
  29.   (help "airbase plus port"))
  30. (unit-type town (image-name "town20") (char "*")
  31.   (help "smaller than a city"))
  32. (unit-type city (image-name "city20") (char "@")
  33.   (help "capital of a side"))
  34.  
  35. (define i infantry)
  36. (define a armor)
  37. (define f fighter)
  38. (define b bomber)
  39. (define d destroyer)
  40. (define s submarine)
  41. (define t troop-transport)
  42. (define cv carrier)
  43. (define bb battleship)
  44. (define nuke nuclear-bomb)
  45. (define / base)
  46. (define * town)
  47. (define @ city)
  48.  
  49. (material-type fuel
  50.   (help "basic supply that all units need"))
  51. (material-type ammo
  52.   (help "generic supply used in combat"))
  53.  
  54. (include "stdterr")
  55.  
  56. (define ground (i a))
  57. (define aircraft (f b))
  58. (define ship (d s t cv bb))
  59. (define cities (* @))
  60. (define places (/ * @))
  61. (define movers (i a f b d s t cv bb nuke))
  62.  
  63. (define water (sea shallows))
  64. (define land (swamp plains forest desert mountains))
  65.  
  66. ;;; Static relationships.
  67.  
  68. (table vanishes-on
  69.   (ground water true)
  70.   (places water true)
  71.   (ship land true)
  72.   (ship road true)
  73.   (u* ice true)
  74.   (aircraft ice false)
  75.   )
  76.  
  77. ;; Unit-unit capacities.
  78.  
  79. ;; Note that carriers have room for up to 8 fighters, but only
  80. ;; two bombers.
  81.  
  82. (table unit-capacity-x
  83.   (cv fighter 4)
  84.   )
  85.  
  86. (table unit-size-as-occupant
  87.   (u* u* 100) ; disables occupancy usually
  88.   ((i nuke) b 1)
  89.   (ground t 1)
  90.   ((f b) cv (1 2))
  91.   (u* / 2)
  92.   (fighter / 1)
  93.   (movers cities 1)
  94.   ;; higher sizes for ships? used to be 6 for bbs, etc
  95.   )
  96.  
  97. (add b capacity 1)
  98. (add t capacity 6)
  99. (add cv capacity 4)
  100. (add places capacity (20 40 80))
  101.  
  102. (table occupant-max (u* u* 99))
  103.  
  104. ;;; Unit-terrain capacities.
  105.  
  106. ;; Limit units to 16 in one cell, for the sake of playability and
  107. ;; and drawability.  Places cover the entire cell, however.
  108.   
  109. (table unit-size-in-terrain
  110.   (u* t* 1)
  111.   (places t* 16)
  112.   )
  113.  
  114. (add t* capacity 16)
  115.  
  116. ;;; Unit-material capacities.
  117.  
  118. (table unit-storage-x
  119.   (u* fuel ( 6 10 18 36 100 100 200 400 200 100 200 500 900))
  120.   (u* ammo ( 6  4  3  3  20  10  20  40  40   0 100 200 400))
  121.   )
  122.  
  123. ;;; Vision.
  124.  
  125. (add cities see-always true)
  126.  
  127. ;; Cities have more powerful radar and sensing systems.
  128.  
  129. (add @ vision-range 3)
  130.  
  131. (table see-chance-adjacent
  132.   (u* s 10)
  133.   (u* nuke 10)
  134.   )
  135.  
  136. ;;; Actions.
  137.  
  138. (add u* acp-per-turn  (1 2 9 6 3 3 2 4 4 1 0 1 1))
  139.  
  140. ;;; Movement.
  141.  
  142. (add places speed 0)
  143.  
  144. (add i free-mp 1)
  145.  
  146. ;; Aircraft should always be able to land.
  147.  
  148. (add aircraft free-mp (9 6))
  149.  
  150. (table mp-to-enter-terrain
  151.   ((cv bb) shallows 2)
  152.   (a (swamp forest mountains) 99)
  153.   ;; No special trouble to get on a road
  154.   ;; (such as when using to cross a river).
  155.   (a road 0)
  156.   (ground water 99)
  157.   (ship land 99)
  158.   (u* ice 99)
  159.   (aircraft ice 1)
  160.   )
  161.  
  162. (table mp-to-traverse (a road 1))
  163.  
  164. (table material-to-move
  165.   (movers fuel 1)
  166.   (nuke fuel 0)
  167.   )
  168.  
  169. (table mp-to-enter-unit
  170.   (u* u* 1)
  171.   ; aircraft can't sortie again until next turn
  172.   (f u* 9)
  173.   (b u* 6)
  174.   (ship u* 0)
  175.   (a cities 0)   ; travel quickly on surrounding roads.
  176.   )
  177.  
  178. (table consumption-per-move
  179.   (movers fuel 1)
  180.   ;; Nukes are "important", a country would never risk them running out.
  181.   (nuke fuel 0)
  182.   )
  183.  
  184. ;;; Construction.
  185.  
  186. ;; Nuclear weapons must be researched before they can be built.
  187.  
  188. (add nuke tech-max 60)
  189. (add nuke tech-to-build 60)
  190.  
  191. ;; Only cities can research nukes.
  192.  
  193. (table acp-to-research (@ nuke 1))
  194.  
  195. (table tech-per-research (@ nuke 1.00))
  196.  
  197. ;; Limit the amount of gain possible due to a concentrated effort.
  198. ;; Note that this will only have an effect in games with many cities.
  199.  
  200. (add nuke tech-per-turn-max 3)
  201.  
  202. ;; Basically, units take about as many turns to complete as their cp.
  203.  
  204. (add u* cp (4 7 8 16 10 16 12 30 40 20 5 1 1))
  205.  
  206. (table acp-to-create
  207.   (i / 1)
  208.   (cities movers 1)
  209.   )
  210.  
  211. (table cp-on-creation
  212.   (ground / (1 2))
  213.   (* movers 1)
  214.   (@ movers 1)
  215.   )
  216.  
  217. (table acp-to-build
  218.   (i / 1)
  219.   (cities movers 1)
  220.   )
  221.  
  222. (table cp-per-build
  223.   (ground / (1 2))
  224.   (* movers 1)
  225.   (@ movers 1)
  226.   )
  227.  
  228. (table occupant-can-construct (u* u* false))
  229.  
  230. ;;; Repair.
  231.  
  232. ;; Some types have sufficient people and redundancy to do repair work
  233. ;; without affecting their readiness to act.
  234.  
  235. (add (cv bb /) hp-recovery 0.50)
  236. (add cities hp-recovery 1.00)
  237.  
  238. ;; Explicit repair actions accelerate the recovery of lost hp.
  239.  
  240. (table acp-to-repair
  241.   (cities u* 1)
  242.   (/ u* 1)
  243.   (cv cv 1)
  244.   (bb bb 1)
  245.   (i places 1)
  246.   )
  247.  
  248. (table hp-per-repair
  249.   (cities u* 1)
  250.   (/ u* 3)
  251.   (cv cv 10)
  252.   (bb bb 10)
  253.   (i places (1 10 10))
  254.   )
  255.  
  256. ;;; Production.
  257.  
  258. (table base-production
  259.   (ground fuel 1)
  260.   (places fuel (10 20 50))
  261.   (places ammo (5 10 20))
  262.   (a fuel 2) ; this is less realistic, but problems otherwise
  263.   )
  264.  
  265. (table productivity
  266.   ;; Plains are assumed to be settled and have fuel stocks.
  267.   (i (swamp desert mountains) 0)
  268.   (a desert 0)
  269.   (/ land (0 100 50 20 20))
  270.   (* land (0 100 50 20 20))
  271.   (@ land (0 100 50 20 20))
  272.   )
  273.  
  274. (table base-consumption
  275.   ((i f b) fuel (1 3 2))  ; note that armor does *not* have a base consumption
  276.   (ship fuel 1)
  277.   )
  278.  
  279. (table hp-per-starve
  280.   ((i f b) fuel 1.00)
  281.   (armor fuel 0.05)
  282.   (ship fuel 0.10)
  283.   (places fuel 0.05)
  284.   )
  285.  
  286. (table consumption-as-occupant
  287.   ((f b) fuel 0)
  288.   )
  289.  
  290. ;;; Combat.
  291.  
  292. (add u* hp-max (1 1 1 2 3 2 3 4 8 1 10 20 40))
  293.  
  294. ;; Units are generally crippled at about 50% of hp-max.
  295.  
  296. ;(add movers hp-at-max-speed (1 1 1 2 2 2 2 2 4 1))
  297. ;(add movers hp-at-min-speed (0 0 0 1 1 1 2 2 1 0))
  298. (add movers speed-min       (0 0 0 3 3 3 2 1 2 1))
  299.  
  300. ;;; The main hit table.
  301.  
  302. (table hit-chance
  303.   (i u* ( 50  40  20  15  20  20  30  20   9  40  80  60  40))
  304.   (a u* ( 60  50  30  30  30  20  30  20  20  50  90  70  50))
  305.   (f u* ( 15  25  60  70  20  30  20  50  40  80 100 100 100))
  306.   (b u* ( 20  20  10   9  30  50  50  70  60  50  90  95  99))
  307.   (d u* (  5   5  10   5  60  70  60  40  20   0  99  90  80))
  308.   (s u* (  0   0  10   5  40  10  60  40  50   0   0   0   0))
  309.   (t u* ( 20   5  10   5  40  40  40  30   9   0   0   0   0))
  310.  (cv u* ( 30  20  40  10  30  30  40  20  20   0   0   0   0))
  311.  (bb u* ( 50  50  50  20  70  50  90  50  90   0 100 100 100))
  312. ;  (nuke u* 100) ; doesn't really matter
  313.   (/ u* ( 10  10  20  20  20  20  30  20  20   0   0   0   0))
  314.   (* u* ( 30  20  50  40  40   0  30  20  20   0   0   0   0))
  315.   (@ u* ( 50  40  70  60  50   0  30  20  50   0   0   0   0))
  316.   )
  317.  
  318. (table damage
  319.   (u* u* 1)
  320.   (a places 2)
  321.   (b ship 2)
  322.   (b s 1)
  323.   (b places (2 2 3))
  324.   (d s 2)
  325.   (s ship 3)
  326.   (s bb 4)
  327.   (bb u* 2)
  328.   (bb cities 3 4)
  329.   )
  330.  
  331. (table capture-chance
  332.   (i places (70 50 30))
  333.   (a places (90 70 50))
  334.   )
  335.  
  336. (table independent-capture-chance
  337.   (i places (100 80 50))
  338.   (a places (100 95 70))
  339.   )
  340.  
  341. ;; Attack and counterattack are completely symmetrical.
  342.  
  343. ;(table counter-strength (u* u* 100))
  344.  
  345. ;; infantry can capture cities even on water.
  346.  
  347. (table bridge (i places true))
  348.  
  349. (table protection ; actually ablation?
  350.   ;; places offer some protection to occupants
  351.   (places movers 50)
  352.   ;; but bases make aircraft sitting ducks, so no protection there.
  353.   (base aircraft 100)
  354.   ;; inf and armor protect the places housing them.
  355.   ;; can't make this too large or city can be
  356.   ;; invulnerable.
  357.   (i places 80)
  358.   (a places 60)
  359.   ; bases benefit more from protection.
  360.   (ground / (50 40))
  361.   )
  362.  
  363. ;; We need ammo to hit with, but no details about types etc.
  364.  
  365. (table consumption-per-attack (u* ammo 1))
  366.  
  367. (table hit-by (u* ammo 1))
  368.  
  369. ;(add ground destroy-message "defeats")
  370. ;(add ship destroy-message "sinks")
  371. ;(add aircraft destroy-message "shoots down")
  372. ;(add places destroy-message "flattens")
  373.  
  374. ;;; Detonation.
  375.  
  376. ;; Nukes work by detonation rather than by conventional attack actions.
  377.  
  378. (add nuke acp-to-detonate 1)
  379.  
  380. (add nuke hp-per-detonation 1)
  381.  
  382. (table detonation-damage-at (nuke u* 60))
  383.  
  384. (table detonation-damage-adjacent (nuke u* 1))
  385.  
  386. (table detonation-terrain-damage-chance
  387.   (nuke (plains forest) 100)
  388.   )
  389.  
  390. (table terrain-damaged-type
  391.   (plains desert 1)
  392.   (forest desert 1)
  393.   )
  394.  
  395. ;;; Disbanding.
  396.  
  397. ;; This does everybody in one shot except battleships, which historically
  398. ;; are usually difficult to scuttle.
  399.  
  400. (add movers acp-to-disband 1)  ; should match speed?
  401. (add bb acp-to-disband 2)
  402.  
  403. (add movers hp-per-disband 4)
  404.  
  405. ;; Takes a while to dismantle a base.
  406.  
  407. (add / hp-per-disband 2)
  408.  
  409. ;;; Changing sides.
  410.  
  411. (add u* acp-to-change-side 1)
  412. (add i acp-to-change-side 0)
  413.  
  414. (add i possible-sides '(not "independent"))
  415.  
  416. ;;; Automatic things.
  417.  
  418. ;; Economy.
  419.  
  420. (table out-length
  421.   ;; Net consumers of supply should never give any up automatically.
  422.   ((i a b f nuke) m* -1)
  423.   ;; Cities and towns can share things around.
  424.   (cities m* 1)
  425.   )
  426.  
  427. (table in-length
  428.   ;; Supply to ground units can go a couple hexes away.
  429.   (ground m* 3)
  430.   ;; Cities and bases can get their supplies from some distance away.
  431.   (/ m* 6)
  432.   (cities m* 12)
  433.   )
  434.  
  435. ;;; Scoring.
  436.  
  437. (add u* point-value 0)
  438. (add (i a nuke) point-value 1)
  439. (add cities point-value (5 25))
  440.  
  441. ;;; Initial setup.
  442.  
  443. (add cities start-with (5 1))
  444. (set country-radius-min 3)
  445. (set country-separation-min 16)
  446. (set country-separation-max 48)
  447. ;; Try to get countries to be on the coast.
  448. (add (sea plains) country-terrain-min (1 4))
  449.  
  450. (table favored-terrain
  451.   (u* t* 0)
  452.   (@ plains 100)
  453.   (* land 20)
  454.   (* plains 40)
  455.   )
  456.  
  457. (table independent-density (town plains 100))
  458.  
  459. (add land country-people-chance 90)
  460. (add plains country-people-chance 100)
  461.  
  462. (add land independent-people-chance 50)
  463.  
  464. (table road-chance (city (town city) (80 100)))
  465.  
  466. ;; A game's starting units will be full by default.
  467.  
  468. (table unit-initial-supply (u* m* 9999))
  469.  
  470. (game-module (notes (
  471.   "This game is the most commonly played one in Xconq.  It"
  472.   "represents units of about 1945, from infantry to atomic bombs.  This is"
  473.   "familiar, which makes it easier to play, but also more controversial,"
  474.   "since historians have many conflicting theories about which kinds of"
  475.   "units were most effective."
  476.   ""
  477.   "Opinions differ about optimal strategy for this game.  In general,"
  478.   "blitzkrieg works, and can win the game in a hurry.  The problem is to"
  479.   "muster enough force before striking.  One full troop transport is not"
  480.   "enough; the invasion will melt away like ice cream on a hot sidewalk,"
  481.   "unless"
  482.   "reinforcements (either air or land) show up quickly.  Air cover is very"
  483.   "important.  While building up an invasion force, airborne assaults using"
  484.   "bombers and infantry can provide useful diversions, although it can be"
  485.   "wasteful of bombers.  Human vs human games on a 60x30 world generally"
  486.   "last about 100 turns, usually not enough time or units to build atomic"
  487.   "bombs or battleships, and not a big enough world to really need carriers"
  488.   "(although bases for staging are quite useful.)"
  489.   )))
  490.  
  491. (add i notes '(
  492.   "The infantry army is the slowest of units, but it can go almost"
  493.   "anywhere.  It is also quick to produce.  Infantry is the staple of"
  494.   "campaigns - no special features, but essential to success."
  495.   ))
  496. (add a notes '(
  497.   "The armor army is highly mobile and hits hard.  Unfortunately,"
  498.   "it is limited to operating in open terrain - plains and desert.  It also"
  499.   "takes longer to produce.  Armor can last twice as long in the  "
  500.   "desert as infantry.  Both armor and infantry can"
  501.   "assault and capture cities; they are the only units that can do so."
  502.   ))
  503. (add f notes '(
  504.   "A fighter is a squadron or wing of high-speed armed aircraft."
  505.   "Their fuel supply can be gotten only at units, towns, and bases, so they"
  506.   "must continually be taking off and landing.  Fighters are not too effective"
  507.   "against ground units or ships, but they eat bombers for lunch.  Fighters"
  508.   "are very good for reconnaisance - important when you can't always"
  509.   "see the enemy moving!"
  510.   ))
  511. (add b notes '(
  512.   "Bombers are very powerful, since they can seriously damage"
  513.   "or even flatten cities.  Loss rate in such activities is high, so they're"
  514.   "not a shortcut to victory!"
  515.   "Bombers can carry one infantry, which is very useful for raids."
  516.   ))
  517. (add d notes '(
  518.   "Destroyers are fast small ships for both exploration and"
  519.   "anti-submarine activities."
  520.   ))
  521. (add s notes '(
  522.   "The favorite food of submarines is of course merchant shipping"
  523.   "and troopships, and they can sink troop transports with one blow."
  524.   "Subs are also invisible, but vulnerable to destroyers and aircraft."
  525.   ))
  526. (add t notes '(
  527.   "This is how ground units get across the sea.  They can"
  528.   "defend themselves against ships and aircraft, but are basically vulnerable."
  529.   "They're not very fast either."
  530.   ))
  531. (add cv notes '(
  532.   "Compensates for the limited range of fighters and bombers by providing"
  533.   "a portable airport.  Carriers themselves are sitting ducks, particularly"
  534.   "with respect to aircraft.  Fighter patrols are mandatory."
  535.   ))
  536. (add bb notes '(
  537.   "The aptly named `Dread Naught' has little to fear from other"
  538.   "units of this period.  Subs may sink them with enough effort, and a group"
  539.   "of bombers and fighters are also deadly,"
  540.   "but with eight hit points to start,"
  541.   "a battleship can usually survive long enough to escape."
  542.   "Battleships are very"
  543.   "effective against cities and armies, at least the ones on the coast."
  544.   ))
  545. (add nuke notes '(
  546.   "Atomic bombs.  The Final Solution; but they are not easy to use.  A bomb"
  547.   "takes a long time to produce, moves very slowly by itself, and is easily"
  548.   "destroyed by other units. The plus side is instant destruction for any unit"
  549.   "of any size!  Bombs are imagined to be transported by a team of scientists,"
  550.   "and can go on any sort of terrain without running out of supplies."
  551.   ))
  552. (add / notes '(
  553.   "To simplify matters, this can serve as a camp, airbase, and port."
  554.   "Bases cannot build units, although they can repair some damage."
  555.   ))
  556. (add * notes '(
  557.   "Towns are the staple of territory.  They can build, repair, produce"
  558.   "fuel and ammo, and serve as a safe haven for quite a few units."
  559.   ))
  560. (add @ notes '(
  561.   "Cities are very large, powerful, and well defended.  They are"
  562.   "basically capital cities, or something in a comparable range.  (New York"
  563.   "and San Francisco are cities, Salt Lake City and San Antonio are towns."
  564.   "Yeah, San Antonio has a lot of people, but it's still insignificant,"
  565.   "nyah nyah.)  A city is worth five towns, point-wise."
  566.   ))
  567.  
  568. (game-module (design-notes (
  569.   "Full transports should move more slowly."
  570.   )))
  571.